package cn.edu.nankai.bookstore.controller.customer;

import cn.edu.nankai.bookstore.domain.po.Customer;
import cn.edu.nankai.bookstore.service.CustomerService;
import cn.edu.nankai.bookstore.service.impl.CustomerServiceImpl;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.math.BigDecimal;

@WebServlet(name = "RegisterServlet", value = "/RegisterServlet")
public class RegisterServlet extends HttpServlet {
    private CustomerService customerService = new CustomerServiceImpl();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String name = (String) request.getParameter("name");
        String tel = (String) request.getParameter("tel");
        String address = (String) request.getParameter("address");
        String pwd = (String) request.getParameter("pwd");
        Boolean status = customerService.register(new Customer(name,new BigDecimal(tel),address,pwd));
        response.getWriter().write(status.toString());
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}
